﻿<UserControl x:Class="Albatross.Shell.Views.CloseWorkspacesConfirmationView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:commonViews="clr-namespace:Albatross.WPF.Common.Views;assembly=Albatross.WPF.Common"
             mc:Ignorable="d" Width="600" MinHeight="300" MaxHeight="500">
	<UserControl.Resources>
		<commonViews:BooleanVisibilityConverter x:Key="bool2visibility" Reversed="True"/>
		<Style TargetType="TextBlock" x:Key="text">
			<Setter Property="FontSize" Value="14"/>
			<Setter Property="Margin" Value="5"/>
			<Setter Property="TextWrapping" Value="Wrap"/>
		</Style>
		<Style TargetType="Button" x:Key="button">
			<Setter Property="Width" Value="80"/>
			<Setter Property="Margin" Value="5"/>
			<Setter Property="BorderBrush" Value="Silver"/>
			<Setter Property="BorderThickness" Value="1"/>
		</Style>
		<DataTemplate x:Key="tree item template">
			<TextBlock>
				<TextBlock Text="{Binding ViewModel.Title}"/>
				<TextBlock Visibility="{Binding CanClose, Converter={StaticResource bool2visibility}}"> *</TextBlock>
				<TextBlock.Style>
					<Style TargetType="TextBlock">
						<Style.Triggers>
							<DataTrigger Binding="{Binding CanClose}" Value="False">
								<Setter Property="Foreground" Value="Red"/>
							</DataTrigger>
						</Style.Triggers>
					</Style>
				</TextBlock.Style>
			</TextBlock>
		</DataTemplate>
		<Style TargetType="TreeViewItem" x:Key="tree view item">
			<Setter Property="ItemsSource" Value="{Binding Children}"/>
			<Setter Property="IsExpanded" Value="True"/>
			<Setter Property="ItemTemplate" Value="{StaticResource tree item template}"/>
		</Style>
	</UserControl.Resources>
	
	<DockPanel>
		<TextBlock DockPanel.Dock="Top" Style="{StaticResource text}">The following workspaces (*) still require to be actioned upon:</TextBlock>
		<DockPanel DockPanel.Dock="Bottom" HorizontalAlignment="Left">
			<Button Style="{StaticResource button}" Command="{Binding ConfirmCommand}" CommandParameter="{Binding (commonViews:Attached.ViewService), RelativeSource={RelativeSource Self}}">OK</Button>
			<Button Style="{StaticResource button}" Command="{Binding CloseCommand}" CommandParameter="{Binding (commonViews:Attached.ViewService), RelativeSource={RelativeSource Self}}">Cancel</Button>
		</DockPanel>
		<TextBlock DockPanel.Dock="Bottom" Style="{StaticResource text}">Are you sure that you want to proceed?</TextBlock>
		<TreeView Margin="5" ItemContainerStyle="{StaticResource tree view item}" ItemsSource="{Binding Workspaces}" ItemTemplate="{StaticResource tree item template}"
				  ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" />
	</DockPanel>
</UserControl>
